<template>
  <div class="box_ft">
    <div class="box_ft_bd" v-show="emojiShow">
      <div class="emoji_panel">
        <ul class="exp_hd">
          <li class="exp_hd_item active" data-i="0">
            <a href="javascript:;">QQ表情</a>
          </li>
          <!--<li class="exp_hd_item" data-i="1">-->
          <!--<a href="javascript:;">符号表情</a>-->
          <!--</li>-->
          <!--<li class="exp_hd_item" data-i="2">-->
          <!--<a href="javascript:;">动画表情</a>-->
          <!--</li>-->
        </ul>
        <div class="exp_bd">
          <div class="exp_cont active" @click="emojiPic($event)">
            <a title="微笑" type="qq" class="qqface qqface0">微笑</a>
            <a title="撇嘴" type="qq" class="qqface qqface1">撇嘴</a>
            <a title="色" type="qq" class="qqface qqface2">色</a>
            <a title="发呆" type="qq" class="qqface qqface3">发呆</a>
            <a title="得意" type="qq" class="qqface qqface4">得意</a>
            <a title="流泪" type="qq" class="qqface qqface5">流泪</a>
            <a title="害羞" type="qq" class="qqface qqface6">害羞</a>
            <a title="闭嘴" type="qq" class="qqface qqface7">闭嘴</a>
            <a title="睡" type="qq" class="qqface qqface8">睡</a>
            <a title="大哭" type="qq" class="qqface qqface9">大哭</a>
            <a title="尴尬" type="qq" class="qqface qqface10">尴尬</a>
            <a title="发怒" type="qq" class="qqface qqface11">发怒</a>
            <a title="调皮" type="qq" class="qqface qqface12">调皮</a>
            <a title="呲牙" type="qq" class="qqface qqface13">呲牙</a>
            <a title="惊讶" type="qq" class="qqface qqface14">惊讶</a>
            <a title="难过" type="qq" class="qqface qqface15">难过</a>
            <a title="酷" type="qq" class="qqface qqface16">酷</a>
            <a title="冷汗" type="qq" class="qqface qqface17">冷汗</a>
            <a title="抓狂" type="qq" class="qqface qqface18">抓狂</a>
            <a title="吐" type="qq" class="qqface qqface19">吐</a>
            <a title="偷笑" type="qq" class="qqface qqface20">偷笑</a>
            <a title="愉快" type="qq" class="qqface qqface21">愉快</a>
            <a title="白眼" type="qq" class="qqface qqface22">白眼</a>
            <a title="傲慢" type="qq" class="qqface qqface23">傲慢</a>
            <a title="饥饿" type="qq" class="qqface qqface24">饥饿</a>
            <a title="困" type="qq" class="qqface qqface25">困</a>
            <a title="惊恐" type="qq" class="qqface qqface26">惊恐</a>
            <a title="流汗" type="qq" class="qqface qqface27">流汗</a>
            <a title="憨笑" type="qq" class="qqface qqface28">憨笑</a>
            <a title="悠闲" type="qq" class="qqface qqface29">悠闲</a>
            <a title="奋斗" type="qq" class="qqface qqface30">奋斗</a>
            <a title="咒骂" type="qq" class="qqface qqface31">咒骂</a>
            <a title="疑问" type="qq" class="qqface qqface32">疑问</a>
            <a title="嘘" type="qq" class="qqface qqface33">嘘</a>
            <a title="晕" type="qq" class="qqface qqface34">晕</a>
            <a title="疯了" type="qq" class="qqface qqface35">疯了</a>
            <a title="衰" type="qq" class="qqface qqface36">衰</a>
            <a title="骷髅" type="qq" class="qqface qqface37">骷髅</a>
            <a title="敲打" type="qq" class="qqface qqface38">敲打</a>
            <a title="再见" type="qq" class="qqface qqface39">再见</a>
            <a title="擦汗" type="qq" class="qqface qqface40">擦汗</a>
            <a title="抠鼻" type="qq" class="qqface qqface41">抠鼻</a>
            <a title="鼓掌" type="qq" class="qqface qqface42">鼓掌</a>
            <a title="糗大了" type="qq" class="qqface qqface43">糗大了</a>
            <a title="坏笑" type="qq" class="qqface qqface44">坏笑</a>
            <a title="左哼哼" type="qq" class="qqface qqface45">左哼哼</a>
            <a title="右哼哼" type="qq" class="qqface qqface46">右哼哼</a>
            <a title="哈欠" type="qq" class="qqface qqface47">哈欠</a>
            <a title="鄙视" type="qq" class="qqface qqface48">鄙视</a>
            <a title="委屈" type="qq" class="qqface qqface49">委屈</a>
            <a title="快哭了" type="qq" class="qqface qqface50">快哭了</a>
            <a title="阴险" type="qq" class="qqface qqface51">阴险</a>
            <a title="亲亲" type="qq" class="qqface qqface52">亲亲</a>
            <a title="吓" type="qq" class="qqface qqface53">吓</a>
            <a title="可怜" type="qq" class="qqface qqface54">可怜</a>
            <a title="菜刀" type="qq" class="qqface qqface55">菜刀</a>
            <a title="西瓜" type="qq" class="qqface qqface56">西瓜</a>
            <a title="啤酒" type="qq" class="qqface qqface57">啤酒</a>
            <a title="篮球" type="qq" class="qqface qqface58">篮球</a>
            <a title="乒乓" type="qq" class="qqface qqface59">乒乓</a>
            <a title="咖啡" type="qq" class="qqface qqface60">咖啡</a>
            <a title="饭" type="qq" class="qqface qqface61">饭</a>
            <a title="猪头" type="qq" class="qqface qqface62">猪头</a>
            <a title="玫瑰" type="qq" class="qqface qqface63">玫瑰</a>
            <a title="凋谢" type="qq" class="qqface qqface64">凋谢</a>
            <a title="嘴唇" type="qq" class="qqface qqface65">嘴唇</a>
            <a title="爱心" type="qq" class="qqface qqface66">爱心</a>
            <a title="心碎" type="qq" class="qqface qqface67">心碎</a>
            <a title="蛋糕" type="qq" class="qqface qqface68">蛋糕</a>
            <a title="闪电" type="qq" class="qqface qqface69">闪电</a>
            <a title="炸弹" type="qq" class="qqface qqface70">炸弹</a>
            <a title="刀" type="qq" class="qqface qqface71">刀</a>
            <a title="足球" type="qq" class="qqface qqface72">足球</a>
            <a title="瓢虫" type="qq" class="qqface qqface73">瓢虫</a>
            <a title="便便" type="qq" class="qqface qqface74">便便</a>
            <a title="月亮" type="qq" class="qqface qqface75">月亮</a>
            <a title="太阳" type="qq" class="qqface qqface76">太阳</a>
            <a title="礼物" type="qq" class="qqface qqface77">礼物</a>
            <a title="拥抱" type="qq" class="qqface qqface78">拥抱</a>
            <a title="强" type="qq" class="qqface qqface79">强</a>
            <a title="弱" type="qq" class="qqface qqface80">弱</a>
            <a title="握手" type="qq" class="qqface qqface81">握手</a>
            <a title="胜利" type="qq" class="qqface qqface82">胜利</a>
            <a title="抱拳" type="qq" class="qqface qqface83">抱拳</a>
            <a title="勾引" type="qq" class="qqface qqface84">勾引</a>
            <a title="拳头" type="qq" class="qqface qqface85">拳头</a>
            <a title="差劲" type="qq" class="qqface qqface86">差劲</a>
            <a title="爱你" type="qq" class="qqface qqface87">爱你</a>
            <a title="NO" type="qq" class="qqface qqface88">NO</a>
            <a title="OK" type="qq" class="qqface qqface89">OK</a>
            <a title="爱情" type="qq" class="qqface qqface90">爱情</a>
            <a title="飞吻" type="qq" class="qqface qqface91">飞吻</a>
            <a title="跳跳" type="qq" class="qqface qqface92">跳跳</a>
            <a title="发抖" type="qq" class="qqface qqface93">发抖</a>
            <a title="怄火" type="qq" class="qqface qqface94">怄火</a>
            <a title="转圈" type="qq" class="qqface qqface95">转圈</a>
            <a title="磕头" type="qq" class="qqface qqface96">磕头</a>
            <a title="回头" type="qq" class="qqface qqface97">回头</a>
            <a title="跳绳" type="qq" class="qqface qqface98">跳绳</a>
            <a title="投降" type="qq" class="qqface qqface99">投降</a>
            <a title="激动" type="qq" class="qqface qqface100">激动</a>
            <a title="乱舞" type="qq" class="qqface qqface101">乱舞</a>
            <a title="献吻" type="qq" class="qqface qqface102">献吻</a>
            <a title="左太极" type="qq" class="qqface qqface103">左太极</a>
            <a title="右太极" type="qq" class="qqface qqface104">右太极</a>
          </div>
          <div class="exp_cont emoji_face" @click="emojiPic($event)"></div>
          <div class="exp_cont tuzki_face" @click="emojiPic($event)"></div>
        </div>
      </div>
    </div>
    <div class="box_ft_hd">
      <div class="eaitWrap">
        <div class="edit-div"
             ref="inputDiv"
             v-html="innerText"
             :contenteditable="canEdit"
             @focus="isLocked = true"
             @blur="isLocked = false"
             @input="changeText">
        </div>
      </div>
      <a href="javascript:;" @click="weChatPicBtn" class="web_wechat_face" id="web_wechat_face"></a>
      <a href="javascript:;" v-show="wePicShow" class="web_wechat_pic" id="web_wechat_pic"></a>
      <a href="javascript:;" v-show="weBtnShow" @click="sendMsg()" class="btn btn_send" id="btn_send">发送</a>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
  export default {
    name: 'editDiv',
    props: {
      value: {
        type: String,
        default: ''
      },
      canEdit: {
        type: Boolean,
        default: true
      }
    },
    data() {
      return {
        innerText: this.value,
        isLocked: false,
        emojiShow: false, // 表情包显示隐藏
        wePicShow: true, // 文件夹图标显示隐藏
        weBtnShow: false, // 发送按钮显示隐藏
        emojiUrl: '', // 选中表情的储存
        getMenuText: '' // 输入的内容
      }
    },
    watch: {
      'value'() {
        if (!this.isLocked || !this.innerText) {
          this.innerText = this.value;
        }
      }
    },
    methods: {
      // 表情栏的显示与隐藏
      weChatPicBtn() {
        console.log(this.innerText)
        var that = this
        if (that.emojiShow === true) {
          that.emojiShow = false
        } else {
          that.emojiShow = true
        }
      },
      changeText() {
        this.$emit('input', this.$el.innerHTML);
        // var getMenuText = this.$refs.inputDiv.innerHTML;
        // console.log(getMenuText)
        // 判断发送按钮的显示和隐藏
        this.getMenuText = this.$refs.inputDiv.innerHTML;
        var getContent = this.getMenuText
        if (getContent.length > 0) {
          this.wePicShow = false;
          this.weBtnShow = true
        } else {
          this.wePicShow = true;
          this.weBtnShow = false
        }
      },
      // 选中表情
      emojiPic(e) {
        // console.log(e)
        var innerHtml = e.target.innerHTML
        var className = e.target.className
        // console.log(innerHtml)
        // console.log(className)
        // this.emojiUrl = '<img title=' + innerHtml + ' class=' + className + ' style="width: 1px;height: 1px">'
        this.emojiUrl = '<img class="' + className + '" title="' + innerHtml + '" style="width: 1px;height: 1px">';
        // console.log(this.emojiUrl)
        this.emojiShow = false
      },
      sendMsg() {
        console.log(this.getMenuText + '' + this.emojiUrl)
      }
    }
  }
</script>
<style rel="stylesheet/scss">
  .box_ft {
    background-color: white;
    padding: 0 6px;
    border-top: 1px solid #ccc;
  }

  .box_ft_hd {
    display: flex;
  }

  .box_ft_hd .eaitWrap {
    flex: 1;
    padding-bottom: 5px;
  }

  .box_ft_hd .editArea {
    overflow-y: auto;
    overflow-x: hidden;
    outline: 0;
    border-bottom: 1px solid #ababab;
    font-size: 14px;
    padding: 0 5px;
    max-height: 2em;
    line-height: 1.4;
    margin-top: 5px;
    outline: none;
    border-top: 0;
    border-left: 0;
    border-right: 0;
    width: 280px;
  }

  .web_wechat_face {
    background: url(./img/ico.png) 0 -805px;
    width: 30px;
    height: 30px;
    vertical-align: middle;
    display: inline-block;
  }

  .web_wechat_pic {
    background: url(./img/ico.png) 0 -1638px;
    width: 30px;
    height: 30px;
    vertical-align: middle;
    display: inline-block;
    margin: 0px 3px;
  }

  .exp_hd {
    overflow: hidden;
    background-color: #F2F2F2;
  }

  .exp_hd_item {
    float: left;
  }

  .exp_hd_item.active {
    background-color: #fff;
    border-top-left-radius: 4px;
    -moz-border-radius-topleft: 4px;
    -webkit-border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    -moz-border-radius-topright: 4px;
    -webkit-border-top-right-radius: 4px;
  }

  .exp_hd_item a {
    display: block;
    text-decoration: none;
    color: #333;
    padding: 5px 10px;
    font-size: 14px;
  }

  .exp_bd {
    overflow: auto;
    background-color: #fff;
  }

  .exp_cont {
    display: none;
    height: 200px;
    padding: 10px 0;
    min-height: 50px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .exp_cont.active {
    display: block;
  }

  .eaitWrap .qqface {
    border: 0;
  }

  .qqface {
    float: left;
    font-size: 0;
    text-indent: -999em;
    border-bottom: 1px solid #F0F0F0;
    border-right: 1px solid #F0F0F0;
    cursor: pointer;
    background: url(./img/face1.png) top left no-repeat;
    width: 28px;
    height: 28px;
    display: inline;
    display: -moz-inline-stack;
    display: inline-block;
    vertical-align: top;
    zoom: 1;
    *display: inline;
  }

  .qqface0 {
    background-position: 0 0;
  }

  .qqface1 {
    background-position: -29px 0;
  }

  .qqface2 {
    background-position: -58px 0;
  }

  .qqface3 {
    background-position: -87px 0;
  }

  .qqface4 {
    background-position: -116px 0;
  }

  .qqface5 {
    background-position: -145px 0;
  }

  .qqface6 {
    background-position: -174px 0;
  }

  .qqface7 {
    background-position: -203px 0;
  }

  .qqface8 {
    background-position: -232px 0;
  }

  .qqface9 {
    background-position: -261px 0;
  }

  .qqface10 {
    background-position: -290px 0;
  }

  .qqface11 {
    background-position: -319px 0;
  }

  .qqface12 {
    background-position: -348px 0;
  }

  .qqface13 {
    background-position: -377px 0;
  }

  .qqface14 {
    background-position: -406px 0;
  }

  .qqface15 {
    background-position: 0 -29px;
  }

  .qqface16 {
    background-position: -29px -29px;
  }

  .qqface17 {
    background-position: -58px -29px;
  }

  .qqface18 {
    background-position: -87px -29px;
  }

  .qqface19 {
    background-position: -116px -29px;
  }

  .qqface20 {
    background-position: -145px -29px;
  }

  .qqface21 {
    background-position: -174px -29px;
  }

  .qqface22 {
    background-position: -203px -29px;
  }

  .qqface23 {
    background-position: -232px -29px;
  }

  .qqface24 {
    background-position: -261px -29px;
  }

  .qqface25 {
    background-position: -290px -29px;
  }

  .qqface26 {
    background-position: -319px -29px;
  }

  .qqface27 {
    background-position: -348px -29px;
  }

  .qqface28 {
    background-position: -377px -29px;
  }

  .qqface29 {
    background-position: -406px -29px;
  }

  .qqface30 {
    background-position: 0 -58px;
  }

  .qqface31 {
    background-position: -29px -58px;
  }

  .qqface32 {
    background-position: -58px -58px;
  }

  .qqface33 {
    background-position: -87px -58px;
  }

  .qqface34 {
    background-position: -116px -58px;
  }

  .qqface35 {
    background-position: -145px -58px;
  }

  .qqface36 {
    background-position: -174px -58px;
  }

  .qqface37 {
    background-position: -203px -58px;
  }

  .qqface38 {
    background-position: -232px -58px;
  }

  .qqface39 {
    background-position: -261px -58px;
  }

  .qqface40 {
    background-position: -290px -58px;
  }

  .qqface41 {
    background-position: -319px -58px;
  }

  .qqface42 {
    background-position: -348px -58px;
  }

  .qqface43 {
    background-position: -377px -58px;
  }

  .qqface44 {
    background-position: -406px -58px;
  }

  .qqface45 {
    background-position: 0 -87px;
  }

  .qqface46 {
    background-position: -29px -87px;
  }

  .qqface47 {
    background-position: -58px -87px;
  }

  .qqface48 {
    background-position: -87px -87px;
  }

  .qqface49 {
    background-position: -116px -87px;
  }

  .qqface50 {
    background-position: -145px -87px;
  }

  .qqface51 {
    background-position: -174px -87px;
  }

  .qqface52 {
    background-position: -203px -87px;
  }

  .qqface53 {
    background-position: -232px -87px;
  }

  .qqface54 {
    background-position: -261px -87px;
  }

  .qqface55 {
    background-position: -290px -87px;
  }

  .qqface56 {
    background-position: -319px -87px;
  }

  .qqface57 {
    background-position: -348px -87px;
  }

  .qqface58 {
    background-position: -377px -87px;
  }

  .qqface59 {
    background-position: -406px -87px;
  }

  .qqface60 {
    background-position: 0 -116px;
  }

  .qqface61 {
    background-position: -29px -116px;
  }

  .qqface62 {
    background-position: -58px -116px;
  }

  .qqface63 {
    background-position: -87px -116px;
  }

  .qqface64 {
    background-position: -116px -116px;
  }

  .qqface65 {
    background-position: -145px -116px;
  }

  .qqface66 {
    background-position: -174px -116px;
  }

  .qqface67 {
    background-position: -203px -116px;
  }

  .qqface68 {
    background-position: -232px -116px;
  }

  .qqface69 {
    background-position: -261px -116px;
  }

  .qqface70 {
    background-position: -290px -116px;
  }

  .qqface71 {
    background-position: -319px -116px;
  }

  .qqface72 {
    background-position: -348px -116px;
  }

  .qqface73 {
    background-position: -377px -116px;
  }

  .qqface74 {
    background-position: -406px -116px;
  }

  .qqface75 {
    background-position: 0 -145px;
  }

  .qqface76 {
    background-position: -29px -145px;
  }

  .qqface77 {
    background-position: -58px -145px;
  }

  .qqface78 {
    background-position: -87px -145px;
  }

  .qqface79 {
    background-position: -116px -145px;
  }

  .qqface80 {
    background-position: -145px -145px;
  }

  .qqface81 {
    background-position: -174px -145px;
  }

  .qqface82 {
    background-position: -203px -145px;
  }

  .qqface83 {
    background-position: -232px -145px;
  }

  .qqface84 {
    background-position: -261px -145px;
  }

  .qqface85 {
    background-position: -290px -145px;
  }

  .qqface86 {
    background-position: -319px -145px;
  }

  .qqface87 {
    background-position: -348px -145px;
  }

  .qqface88 {
    background-position: -377px -145px;
  }

  .qqface89 {
    background-position: -406px -145px;
  }

  .qqface90 {
    background-position: 0 -174px;
  }

  .qqface91 {
    background-position: -29px -174px;
  }

  .qqface92 {
    background-position: -58px -174px;
  }

  .qqface93 {
    background-position: -87px -174px;
  }

  .qqface94 {
    background-position: -116px -174px;
  }

  .qqface95 {
    background-position: -145px -174px;
  }

  .qqface96 {
    background-position: -174px -174px;
  }

  .qqface97 {
    background-position: -203px -174px;
  }

  .qqface98 {
    background-position: -232px -174px;
  }

  .qqface99 {
    background-position: -261px -174px;
  }

  .qqface100 {
    background-position: -290px -174px;
  }

  .qqface101 {
    background-position: -319px -174px;
  }

  .qqface102 {
    background-position: -348px -174px;
  }

  .qqface103 {
    background-position: -377px -174px;
  }

  .qqface104 {
    background-position: -406px -174px;
  }

  /*表情end*/

  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  ::-webkit-scrollbar-thumb {
    border-radius: 3px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    background-color: #c3c3c3;
  }

  ::-webkit-scrollbar-track {
    background-color: transparent;
  }

  a.btn {
    text-decoration: none;
  }

  .btn {
    display: inline-block;
    border-radius: 4px;
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    padding: 2px 4px;
    font-size: 14px;
    height: 20px;
    line-height: 20px;
    margin-top: 3px;
    cursor: pointer;
  }

  .btn_send {
    background-color: #5CB700;
    color: white;
    height: 25px;
    text-align: center;
    line-height: 25px;
  }
  .edit-div {
    width: 100%;
    height: 100%;
    overflow: auto;
    word-break: break-all;
    outline: none;
    user-select: text;
    white-space: pre-wrap;
    text-align: left;
    /*border-bottom: 1px solid #ababab;*/
   /*&:[contenteditable=true] {*/
      /*user-modify: read-write-plaintext-only;*/
      /*&:empty:before {*/
        /*content: attr(placeholder);*/
        /*display: block;*/
        /*color: #ccc;*/
      /*}*/
    /*}*/
  }
</style>
